<?php
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL & ~E_NOTICE);
set_time_limit(0);

require_once($_SERVER['DOCUMENT_ROOT'] . '/all.conf.php');
require_once(__PHY_LIB.'/class/FnOrder.class.php');

$oList = new OrderList();
$oList->cfgWhere("status='unpaid' AND time_added<'".date('Y-m-d H:i:s', time() - 7200)."'"); // 2小时不付钱的
$oList->cfgOrder("id");
$oList->load();
$nCnt = 0;
while ($oOne = $oList->nextItem()) {
	$oOne->set('status', 'canceled');
	$oOne->update();
	$oOne->releaseStockLock();
	echo "Order ID=",$oOne->getID()," canceled, stock released<br />\n";
	$nCnt++;
}
echo "({$nCnt}) Order affected.";
?>
